package com.hernie.user.controller;

import com.hernie.user.pojo.User;
import com.hernie.user.service.RegisterService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Map;

@Controller
public class RegisterController {
    @Resource
    private RegisterService registerService;
    @PostMapping("/Register")
    @ResponseBody
    public Map<String, Object> register(@RequestBody User user){
        System.out.println("register");
        return registerService.register(user);
    }
    @GetMapping("/checkEmail")
    public String checkEmail(@RequestParam("code") String code, HttpSession session) throws IOException {
//        response.sendRedirect("/index.html");
//        System.out.println(code);
//        return registerService.checkEmail(code, session);
        return registerService.checkEmail(code, session);
    }
}
